package com.rp.demo.config;

import cn.hutool.json.JSONUtil;
import com.rp.demo.commons.Constant;
import com.rp.demo.entity.MsgLog;
import com.rp.demo.service.MsgLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * 用户测试拉取功能申请的对象及其Exchange信息
 * 注意: 在rabbitconfig中有rabbittemplate的配置相关的信息
 */
@Configuration
@Slf4j
public class RabbitLaQuConfig {

    // 发送邮件
    public static final String LAQU_QUEUE_NAME = "laqu.queue";
    public static final String LAQU_EXCHANGE_NAME = "laqu.exchange";
    public static final String LAQU_ROUTING_KEY_NAME = "laqu.routing.key";



    @Bean
    public Queue laquQueue() {
        return new Queue(LAQU_QUEUE_NAME, true);
    }
 
    @Bean
    public DirectExchange laquExchange() {
        return new DirectExchange(LAQU_EXCHANGE_NAME, true, false);
    }
 
    @Bean
    public Binding laquBinding() {
        return BindingBuilder.bind(laquQueue()).to(laquExchange()).with(LAQU_ROUTING_KEY_NAME);
    }
 
}